package com.jianggujin.demo.listener;

import org.springframework.stereotype.Component;

import com.jianggujin.modulelink.config.JModuleConfig;
import com.jianggujin.modulelink.module.JModuleListener;
import com.jianggujin.modulelink.module.JModuleState;
import com.jianggujin.modulelink.util.JLogFactory;
import com.jianggujin.modulelink.util.JLogFactory.JLog;

@Component
public class ModuleListener implements JModuleListener {
    private JLog logger = JLogFactory.getLog(ModuleListener.class);

    public ModuleListener() {
        logger.info("instance listener by classloader:" + getClass().getClassLoader());
    }

    @Override
    public void onStateChanged(JModuleConfig moduleConfig, JModuleState oldModuleState, JModuleState newModuleState) {
        logger.info("onStateChanged,module name:{}, from:{}, to:{}", moduleConfig.getModuleName(), oldModuleState,
                newModuleState);
    }
}
